package org.springcloud.wisdom.amusement.controller.sys;

import org.springcloud.wisdom.amusement.bean.ResponseData;
import org.springcloud.wisdom.amusement.controller.BaseController;
import org.springcloud.wisdom.amusement.entity.Team_Student;
import org.springcloud.wisdom.amusement.service.ITeam_StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/sys/team")
public class Team_StudentController extends BaseController {
    @Autowired
    ITeam_StudentService teamStudentService;
    //通过社团id，获取社团成员
    @GetMapping("gets")
    public ResponseData<Object> getTeamStudent(Integer teamid) {
        return returnObject(teamStudentService.watchTeamStudent(teamid));
    }
    //通过社团id，获取社团成员分页
    @GetMapping("gets1")
    public ResponseData<Object> getTeamStudentPage(int pageNum, int pageSize,Integer teamid) {
        return returnObject(teamStudentService.watchTeamStudentPage(pageNum, pageSize, teamid));
    }

    //获取报名学生
    @GetMapping("gets2")
    public ResponseData<Object> getAddTeamStudent(Integer teamid) {
        return returnObject(teamStudentService.watchAddTeamStudent(teamid));
    }
    //获取报名学生
    @GetMapping("gets22")
    public ResponseData<Object> getAddTeamStudentPage(int pageNum, int pageSize,Integer teamid) {
        return returnObject(teamStudentService.watchAddTeamStudentPage(pageNum, pageSize, teamid));
    }

    //申请加入社团
    @PostMapping("add")
    public ResponseData<Boolean> addTeamStudent(Team_Student teamStudent) {
        return returnBoolean(teamStudentService.wantAddTeamStudent(teamStudent));
    }

    //删除社员
    @PutMapping("delete2")
    public ResponseData<Boolean> delTeamStudent(@RequestBody Team_Student teamStudent) {
        return returnBoolean(teamStudentService.delTeamStudent(teamStudent));
    }
    //审核通过
    @PutMapping("update")
    public ResponseData<Boolean> realAddTeamStudent(@RequestBody Team_Student teamStudent) {
        return returnBoolean(teamStudentService.permitAddTeamStudent(teamStudent));
    }
    //审核失败 后面改逻辑删除
    @DeleteMapping("delete")
    public ResponseData<Boolean> deleteTeamStudent(String sid, Integer teamid) {
        return returnBoolean(teamStudentService.unpermitAddTeamStudent(sid, teamid));
    }


}
